int sensorPin = 0;
int ledPin = 9;
int sensorValue = 0;
long previousMillis = 0;
long interval = 10;
int brightness = 180;
unsigned long currentMillis = 0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  currentMillis = millis();
  LEDTimer(currentMillis);
}

void LEDTimer(int currentMillis) {
  if (currentMillis - previousMillis > interval) {
    previousMillis = currentMillis;
    lightLED();
    readBrightness();
  }
}

void lightLED() {
    analogWrite(ledPin, brightness);  
}

void readBrightness() {
  sensorValue = analogRead(sensorPin);
//  if (sensorValue > 0) {
//    Serial.println(sensorValue);
//  }
  
  brightness = (sensorValue * 100);
  if (brightness < 100) {
    brightness = 100;
  } else if (brightness > 255) {
    brightness = 255;
  }
}
